#ifndef __BSP_QUEUE_H__
#define __BSP_QUEUE_H__

#include <stdint.h> 

#include "bsp_typedef.h"

typedef uint8_t queue_elem_t; 

typedef struct
{
    int16_t r_index;  /* 读指针 */
    int16_t w_index;  /* 写指针 */
    int16_t max_len;  /* 队列的最大长度 */
    int16_t cur_len;  /* 当前队列长度(队列的元素个数) */
    uint8_t *buffer;  /* 缓存数据指针 */
}queue_t;



BOOL queue_init(queue_t *q, queue_elem_t *buf, int16_t length);
BOOL queue_clear(queue_t *q);

BOOL queue_is_empty(queue_t *q);
BOOL queue_is_full(queue_t *q);

int16_t queue_length(queue_t * q);
int16_t queue_unused(queue_t * q);

int16_t queue_enter(queue_t *q, queue_elem_t data);
int16_t queue_delete(queue_t *q, queue_elem_t *data);

int16_t queue_enter_buffer(queue_t * q, queue_elem_t *buf, int16_t len);
int16_t queue_delete_buffer(queue_t *q, queue_elem_t *buf, int16_t len);

#endif /* __BSP_QUEUE_H__ */

